
<extend name="Error:base" />
<block name="title"><title>生成订单</title></block>
		<block name="style2">
			<link href="__PUBLIC__/Home/css/base.css" rel="stylesheet" type="text/css">	
			<style>
				form a{text-decoration:underline;}
			</style>
		</block>		
		<block name="style">
			<link href="__PUBLIC__/Home/css/home_cart.css" rel="stylesheet" type="text/css"><link href="__PUBLIC__/Home/css/perfect-scrollbar.min.css" rel="stylesheet" type="text/css">			
		</block>
		<block name="script2">

<script>
	var COOKIE_PRE = 'F8DD_';
	var _CHARSET = 'utf-8';
	var SITEURL = window.location.host;
	var MEMBER_SITE_URL =  window.location.host;
	var RESOURCE_SITE_URL =  window.location.host;
	var RESOURCE_SITE_URL =  window.location.host;
	var SHOP_TEMPLATES_URL =  window.location.host;
	var PRICE_FORMAT = '&yen;%s';
	Number.prototype.toFixed = function(d)
	{
		var s=this+"";if(!d)d=0;
		if(s.indexOf(".")==-1)s+=".";s+=new Array(d+1).join("0");
		if (new RegExp("^(-|\\+)?(\\d+(\\.\\d{0,"+ (d+1) +"})?)\\d*$").test(s))
		{
			var s="0"+ RegExp.$2, pm=RegExp.$1, a=RegExp.$3.length, b=true;
			if (a==d+2){a=s.match(/\d/g); if (parseInt(a[a.length-1])>4)
			{
				for(var i=a.length-2; i>=0; i--) {a[i] = parseInt(a[i])+1;
				if(a[i]==10){a[i]=0; b=i!=1;} else break;}
			}
			s=a.join("").replace(new RegExp("(\\d+)(\\d{"+d+"})\\d$"),"$1.$2");
		}if(b)s=s.substr(1);return (pm+s).replace(/\.$/, "");} return this+"";
	};
</script>
			<script src="__PUBLIC__/Home/js/jquery.validation.min.js"></script>
			<script src="__PUBLIC__/Home/js/jquery.poshytip.min.js"></script>
			<script type="text/javascript" src="__PUBLIC__/Home/js/perfect-scrollbar.min.js"></script>
			<script type="text/javascript" src="__PUBLIC__/Home/js/jquery.mousewheel.js"></script>
			<script type="text/javascript" src="__PUBLIC__/Home/js/dialog.js" id="dialog_js" charset="utf-8"></script><link href="__PUBLIC__/Home/css/dialog.css" rel="stylesheet" type="text/css">
			<script src="__PUBLIC__/Home/js/goods_cart.js"></script>
		</block>
<block name="body">
<header class="ncc-head-layout">
    <div class="site-logo"><a href="/">
				<volist name="service" id="vo">
				<eq name="vo.name" value="net_logo" >
					<if condition="$vo.value neq ''">
					<img src="{$vo.value}" class="pngFix">
					<else/>
						<volist name="service" id="vo">
						<eq name="vo.name" value="net_logo" >
							<if condition="$vo.value neq ''">
							<img src="{$vo.value}" class="pngFix">
							<else/>
							<img src="__PUBLIC__/Home/images/logo.png" class="pngFix">
							</if>
						</eq>
						</volist>
					</if>
				</eq>
				</volist>	
	</a></div>
        <ul class="ncc-flow">
      <li class=""><i class="step1"></i>
        <p>我的购物车</p>
        <sub></sub>
        <div class="hr"></div>
      </li>
      <li class=""><i class="step2"></i>
        <p>确认订单</p>
        <sub></sub>
        <div class="hr"></div>
      </li>
      <li class="current"><i class="step3"></i>
        <p>支付提交</p>
        <sub></sub>
        <div class="hr"></div>
      </li>
      <li class=""><i class="step4"></i>
        <p>订单完成</p>
        <sub></sub>
        <div class="hr"></div>
      </li>
    </ul>
</header>


	  
<div class="ncc-wrapper"> 
<div class="ncc-main">
  <div class="ncc-title">
    <h3>支付提交</h3>
    <h5>订单详情内容可通过查看<a href="" target="_blank">我的订单</a>进行核对处理。</h5>
  </div>
  <form action="{:U('shop/order_pay_1')}" method="POST" id="buy_form">
    <input type="hidden" name="pay_sn" value="{$pay_sn}">
    <input type="hidden" id="payment_code" name="payment_code" value="">
		<foreach name="order_list" item="vo">
          	<input type="hidden" id="order_sn" name="order_sn" value="{$vo.order_sn}">
			<input type="hidden" id="order_id" name="order_id" value="{$vo.order_id}">
		 </foreach>

    <input type="hidden" value="" name="password_callback" id="password_callback">
    <div class="ncc-receipt-info">
      <div class="ncc-receipt-info-title">
        <h3>
        请您及时完成支付。应付金额：<strong>{$m_html}</strong>        </h3>
      </div>
      <table class="ncc-table-style">
        <thead>
          <tr>
            <th class="w50"></th>
            <th class="w200 tl">订单号</th>
            <th class="tl w150">支付方式</th>
            <th class="tl">金额(元)</th>
          </tr>
        </thead>
        <tbody>
		<foreach name="order_list" item="vo">
          <tr>
            <td></td>
            <td class="tl">{$vo.order_sn}</td>
            <td class="tl">{$pay_name}</td>
            <td class="tl">{$vo.m_html}</td>
          </tr>
		 </foreach>
       </tbody>
      </table>
     <if condition="$spn eq ''">  
      <!-- S 预存款 & 充值卡 -->
	  <if condition="$s_pay neq 1">
	  
	  <in name="pay_mm" value="consume,points,points_consume,coinpay">
      <dl class="ncc-pd-pay">
          <dt>使用余额支付</dt>		  
		  <in name="pay_arr" value="1">
		  <dd>
			 <label><input type="checkbox" class="checkbox" value="{$pay_mm}" name="rcb_pay">
          使用积分支付</label> （可用余额：<em>{$UserInfo[integral1]+$UserInfo[integral2]+$UserInfo[integral5]}</em>元）
		  </dd>
		  <dd>
			 <label><input type="checkbox" class="checkbox" value="{$pay_mm}" name="pd_pay">
          使用余额支付</label> （可用余额：<em>{$UserInfo.member_balance}</em>元）
		  </dd>
		  </in>

		   <in name="pay_mm" value="coinpay,consume,points">
		  <dd>
			 <label><input type="checkbox" class="checkbox" value="{$pay_mm}" name="rcb_pay">
          使用{$pay_name}</label> （可用余额：
			  <in name="pay_mm" value='coinpay' >
			  <em>{$UserInfo.gold_coin}</em>
			  </in>
			  <in name="pay_mm" value='consume' >
			  <em>{$UserInfo.member_balance}</em>
			  </in>
			  <in name="pay_mm" value='points' >
			  <em>{$UserInfo[integral1]+$UserInfo[integral2]+$UserInfo[integral5]}</em>
			  </in>
		  元）
		  </dd>		  
		  </in>

		  <dd>	
			（同时勾选时，系统将优先使用消费积分，不足时扣除消费账户）<!-- ，目前还需在线支付 <strong id="api_pay_amount">198.00</strong>元。）余额不足？	
				<a href="" class="predeposit">马上充值</a> -->
		  </dd>
          <dd id="pd_password" style="display: none;">请输入支付密码
				<input type="password" value="" name="password" id="pay-password" maxlength="35" autocomplete="off">
				<a href="javascript:void(0);" class="ncbtn-mini ncbtn-bittersweet" id="pd_pay_submit"><i class="icon-shield"></i>确认支付</a>
            还未设置支付密码，<a href="" target="_blank">马上设置</a>
            </dd>		  
        </dl>
		</in>
		</if>
	</if>
    </div>
	 <if condition="$spn eq ''">  
	 <if condition="$pay_type eq 1">
       <div class="ncc-receipt-info">
          <div class="ncc-receipt-info-title">
            <h3>选择在线支付</h3>
          </div>
          <ul class="ncc-payment-list">
				<foreach name="pay_list" item="pvo">
				<in name="pvo.payment_code" value="alipay">
				<li payment_code="alipay">
				  <label for="pay_alipay">
				  <i></i>
				  <div class="logo" for="pay_2"> <img src="__PUBLIC__/Home/images/alipay_logo.gif"> </div>
				  </label>
				</li>
				</in>
				<in name="pvo.payment_code" value="tenpay">
				<li payment_code="tenpay">
				  <label for="pay_tenpay">
				  <i></i>
				  <div class="logo" for="pay_3"> <img src="__PUBLIC__/Home/images/tenpay_logo.gif"> </div>
				  </label>
				</li>
				</in>
				<in name="pvo.payment_code" value="chinabank">
			   <li payment_code="chinabank">
				  <label for="pay_chinabank">
				  <i></i>
				  <div class="logo" for="pay_4"> <img src="__PUBLIC__/Home/images/chinabank_logo.gif"> </div>
				  </label>
				</li>
				</in>
				<in name="pvo.payment_code" value="wxpay">
			   <li payment_code="wxpay">
				  <label for="pay_wxpay">
				  <i></i>
				  <div class="logo" for="pay_6"> <img src="__PUBLIC__/Home/images/wxpay_logo.gif"> </div>
				  </label>
				</li>
				</in>
				</foreach>
          </ul>
        </div>
		</if>
		
         <div class="ncc-bottom"><a href="javascript:void(0);" id="next_button" class="pay-btn"><i class="icon-shield"></i>确认支付</a></div>
		 <else/>
			 <div class="ncc-bottom"><a href="/member/swjydd"  class="pay-btn"><i class="icon-shield"></i>进会员中心支付订单</a></div>
		 </if>
      </form>
</div>
<script type="text/javascript">
var pay_amount_online = 198;
var member_rcb = 0;
var member_pd = 0;
var pay_diff_amount = 198;
$(function(){
    $('.ncc-payment-list > li').on('click',function(){
    	$('.ncc-payment-list > li').removeClass('using');
    	if ($('#payment_code').val() != $(this).attr('payment_code')) {
    		$('#payment_code').val($(this).attr('payment_code'));
    		$(this).addClass('using');
        } else {
            $('#payment_code').val('');
        }
    });
    $('#next_button').on('click',function(){
    	if (($('input[name="pd_pay"]').attr('checked') || $('input[name="rcb_pay"]').attr('checked')) && $('#password_callback').val() != '1') {
    		showDialog('需输入支付密码并确认  ', 'error','','','','','','','',2);
    		return;
    	}
        if ($('#password_callback').val()== '' && $('#payment_code').val() == '' && parseFloat($('#api_pay_amount').html()) > 0) {
        	showDialog('请选择一种在线支付方式', 'error','','','','','','','',2);
        	return;
        }
        $('#buy_form').submit();
    });

            function showPaySubmit() {
            if ($('input[name="pd_pay"]').attr('checked') || $('input[name="rcb_pay"]').attr('checked')) {
            	$('#pay-password').val('');
            	$('#password_callback').val('');
            	$('#pd_password').show();
            } else {
            	$('#pd_password').hide();
            }
            var _diff_amount = pay_diff_amount;
        	if ($('input[name="rcb_pay"]').attr('checked')) {
        		_diff_amount -= member_rcb;
            }
     	    _diff_amount = parseFloat(_diff_amount.toFixed(2));
        	if ($('input[name="pd_pay"]').attr('checked')) {
        		_diff_amount -= member_pd;
            }
        	_diff_amount = parseFloat(_diff_amount.toFixed(2));
            if (_diff_amount < 0) {
            	_diff_amount = 0;
            }
            $('#api_pay_amount').html(_diff_amount.toFixed(2));
        }
    
        $('#pd_pay_submit').on('click',function(){
            if ($('#pay-password').val() == '') {
            	showDialog('请输入支付密码', 'error','','','','','','','',2);return false;
            }
            $('#password_callback').val('');
			var url = "{:U('buy/pay_puw')}" ;

			$.ajax({
				url:url,
				data:{password:$('#pay-password').val()},
				type:'post',
				dataType:'json',
				success:function (data) {
					if (data == '1') {
						$('#password_callback').val('1');
						$('#pd_password').hide();
					} else {
						$('#pay-password').val('');
						showDialog('支付密码错误', 'error','','','','','','','',2);
					}
					
				}
			});	
			
        });
    
        $('input[name="rcb_pay"]').on('change',function(){
        	showPaySubmit();
        	if ($(this).attr('checked') && !$('input[name="pd_pay"]').attr('checked')) {
            	if (member_rcb >= pay_amount_online) {
                	$('input[name="pd_pay"]').attr('checked',false).attr('disabled',true);
            	}
        	} else {
        		$('input[name="pd_pay"]').attr('disabled',false);
        	}
        });
    
        $('input[name="pd_pay"]').on('change',function(){
        	showPaySubmit();
        	if ($(this).attr('checked') && !$('input[name="rcb_pay"]').attr('checked')) {
            	if (member_pd >= pay_amount_online) {
                	$('input[name="rcb_pay"]').attr('checked',false).attr('disabled',true);
            	}
        	} else {
        		$('input[name="rcb_pay"]').attr('disabled',false);
        	}
        });
    });
</script>
</div>        

	  	  

</br>
</br>
</br>
</br>
</block>	


